{extend name="admin@index_layout"/}
{block name="main"}

<div class="layui-card">
    <div class="layui-card-header">评价列表</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-add="{:$auth->check('comment.comment/add')}"
               data-auth-edit="{:$auth->check('comment.comment/edit')}"
               data-auth-delete="{:$auth->check('comment.comment/del')}"
        ></table>
    </div>
</div>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="显示|关闭" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>


<script type="text/html" id="barTool">

    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="查看"
       data-full="true">查看</a>

    <a href='{:url("del",["catid"=>$catid])}?ids={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>

</script>


{/block}
{block name="script"}
<script>
    var selectElement=null;
    layui.use('yznTable', function () {
        var table = layui.yznTable;
        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: "{:url('add')}",
            edit_url: "{:url('edit')}",
            delete_url: "{:url('del')}",
        };
        //订单类型 订单编号 服务人员 服务人员电话
        table.render({
            init: init,
            autoWidth: true,
            toolbar: ['refresh',],
            url: '{:url("index")}',
            cols: [
                [
                    {field: 'id', width: '4%', title: 'ID'},
                    {field: 'nickname', align: "center", width: '10%', title: '会员昵称', searchOp: 'like'},
                    {field: 'mobile', align: "center", width: '10%', title: '电话'},
                    // {field: 'type', align: "center", width: '10%', title: '订单类型'},
                    {
                        field: 'type', align: "center", width: '8%', title: '订单类型', templet: function (d) {
                            if (d.type == 1) {
                                return '<span style="color: red">导诊</span>';
                            } else if (d.type == 2) {
                                return '<span style="color: green">陪诊</span>';
                            }else if (d.type == 3) {
                                return '<span style="color: #0000FF">司机接送</span>';
                            } else {
                                return '<span>未知</span>';
                            }
                        }, selectList: {1:'导诊',2:'陪诊',3:'司机接送'}
                    },
                    {field: 'order_no', align: "center", width: '20%', title: '订单编号'},
                    {field: 'people_name', align: "center", width: '15%', title: '服务/驾驶人员',search: false},
                    {field: 'phone', align: "center", width: '15%', title: '服务/驾驶人员电话',search: false},
                    // {
                    //     field: 'province',
                    //     align: "center",
                    //     width: '15%',
                    //     title: '省',
                    //     hide: true,
                    //     selectList: {}
                    // },
                    // {field: 'city', align: "center", width: '15%', title: '市',hide: true,
                    //     selectList: {}},
                    {
                        field: 'status',
                        width: '10%',
                        align: "center",
                        title: '状态',
                        templet: '#statusTpl',
                        unresize: true,
                        selectList: {1: '显示', 0: '隐藏'}
                    },
                    {field: 'score', align: "center", width: '8%', title: '评分',search: false},
                    {field: 'create_time', align: "center", width: '20%', title: '创建时间',search: false},
                    {fixed: 'right', align: "center", width: '15%', title: '操作', toolbar: '#barTool'}//delete'
                ]
            ],
            page: {}
        });
        yznTable.bindevent();
        // selectElement = document.getElementById('c-province');
        // selectElement.setAttribute("lay-filter", "c-province");
        form1();
        selectElement2 = document.getElementById('searchFieldset_currentTable');
        selectElement2.classList.remove("layui-hide");
        var element = document.getElementById('layui-input-search');
        element.parentNode.removeChild(element);

    });
    function form1(){
        layui.use('form', function () {
            var form = layui.form;
            form.on('select(c-province)', function (data) {
                console.log(data.value);
                $.ajax({
                    type: "POST",//规定传输方式
                    url: "{:url('getc_cate')}",//提交URL
                    data: {'id':data.value},//提交的数据
                    success: function(result){
                        if(result.code == 200){
                            $("#c-city").empty();
                            var str = "<option value>- 全部 -</option>";
                            $.each(result.data, function(i, val){
                                str += '<option value='+val.id+'>'+val.name+'</option>'
                            });
                            $("#c-city").append(str);
                            layui.form.render('select');
                        }
                    },
                    error: function() {
                        alert("获取信息失败")
                    }
                });
            })
        });
    }




</script>
{/block}